home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / FLTK-1.0.6 / test / browserop.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-07  |  3.2 KB  |  109 lines

  1. //
  2. // "$Id: browserop.cxx,v 1.4 1999/01/07 19:17:49 mike Exp $"
  3. //
  4. // Browser operation test program for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-1999 by Bill Spitzak and others.
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems to "fltk-bugs@easysw.com".
  24. //
  25.  
  26. #include "forms.h"
  27.  
  28. FL_FORM *form;
  29. FL_OBJECT *browserobj, *inputobj, *exitobj;
  30.  
  31. void addit(FL_OBJECT *, long)
  32. {
  33.   /* append and show the last line. Don't use this if you just want
  34.    * to add some lines. use fl_add_browser_line
  35.    */
  36.   fl_addto_browser(browserobj,fl_get_input(inputobj));
  37. }
  38.  
  39. void insertit(FL_OBJECT *, long)
  40. {
  41.   int n;
  42.   if (! ( n = fl_get_browser(browserobj))) return;
  43.   fl_insert_browser_line(browserobj,n,fl_get_input(inputobj));
  44. }
  45.  
  46. void replaceit(FL_OBJECT *, long)
  47. {
  48.   int n;
  49.   if (! (n=fl_get_browser(browserobj))) return;
  50.   fl_replace_browser_line(browserobj,n,fl_get_input(inputobj));
  51. }
  52.  
  53. void deleteit(FL_OBJECT *, long)
  54. {
  55.   int n;
  56.   if (! (n = fl_get_browser(browserobj))) return;
  57.   fl_delete_browser_line(browserobj,n);
  58. }
  59.  
  60. void clearit(FL_OBJECT *, long)
  61. {
  62.   fl_clear_browser(browserobj);
  63. }
  64.  
  65. /*---------------------------------------*/
  66.  
  67. void create_form(void)
  68. {
  69.   FL_OBJECT *obj;
  70.  
  71.   form = fl_bgn_form(FL_UP_BOX,390,420);
  72.   browserobj = fl_add_browser(FL_HOLD_BROWSER,20,20,210,330,"");
  73. //  fl_set_object_dblbuffer(browserobj, 1);
  74.   inputobj = obj = fl_add_input(FL_NORMAL_INPUT,20,370,210,30,"");
  75.     fl_set_object_callback(obj,addit,0);
  76.     obj->when(FL_WHEN_ENTER_KEY|FL_WHEN_NOT_CHANGED);
  77.   obj = fl_add_button(FL_NORMAL_BUTTON,250,20,120,30,"Add");
  78.     fl_set_object_callback(obj,addit,0);
  79.   obj = fl_add_button(FL_NORMAL_BUTTON,250,60,120,30,"Insert");
  80.     fl_set_object_callback(obj,insertit,0);
  81.   obj = fl_add_button(FL_NORMAL_BUTTON,250,100,120,30,"Replace");
  82.     fl_set_object_callback(obj,replaceit,0);
  83.   obj = fl_add_button(FL_NORMAL_BUTTON,250,160,120,30,"Delete");
  84.     fl_set_object_callback(obj,deleteit,0);
  85.   obj = fl_add_button(FL_NORMAL_BUTTON,250,200,120,30,"Clear");
  86.     fl_set_object_callback(obj,clearit,0);
  87.   exitobj = fl_add_button(FL_NORMAL_BUTTON,250,370,120,30,"Exit");
  88.   fl_end_form();
  89. }
  90.  
  91. /*---------------------------------------*/
  92.  
  93. int
  94. main(int argc, char *argv[])
  95. {
  96.   FL_OBJECT *obj;
  97.  
  98.   fl_initialize(&argc, argv, "FormDemo", 0, 0);
  99.   create_form();
  100.   fl_show_form(form,FL_PLACE_CENTER,FL_TRANSIENT,"Browser Op");
  101.   do obj = fl_do_forms(); while (obj != exitobj);
  102.   fl_hide_form(form);
  103.   return 0;
  104. }
  105.  
  106. //
  107. // End of "$Id: browserop.cxx,v 1.4 1999/01/07 19:17:49 mike Exp $".
  108. //
  109.